<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>编辑</title>
	<%@include file="../common/header.jsp" %>  
	<script type="text/javascript" src="${pathUrl }/public/js/PCASClass.js"></script>
    <script type="text/javascript">
        window.onload=function(){
            //初始化省市区
            var mypcas = new PCAS("province,所属省份","city,所属城市","area,所属地区");
        }
    </script>
</head>
<body>
<%@include file="../common/top.jsp" %>
<div class="section clearfix" style="margin-top: 10px;">
    <!--页面左边-->
   	 <%@include file="left.jsp" %>
    <!--/页面左边-->
    
<form action="${pathUrl }/home/center/submitAddEditorAddress" onsubmit="return submitAddress()" id="formMain" method="post">
    <!--页面左边-->
    <div class="right-auto">
        <div class="bg-wrap" style="min-height:765px;">
            <div class="sub-tit " style="margin: 0px;">
                <a class="add" href="${pathUrl }/home/center/addressIndex"><i class="iconfont icon-reply"></i>返回</a>
                <ul>
                    <li class="selected">
                        <a href="javascript:;">新增地址</a>
                    </li>
                </ul>
            </div>
            <div class="form-box">
                <dl class="form-group">
                    <dt>收件人姓名：</dt>
                    <dd>
                        <input name="username" id="username" value="" type="text" class="input" >
                        <span class="Validform_checktip"></span></dd>
                </dl>
                <dl class="form-group">
                    <dt>所属地区：</dt>
                    <dd>
                        <select id="province" name="province" class="select"></select>
                        <select id="city" name="city" class="select"></select>
                        <select id="area" name="area" class="select" ></select>
                        <span class="Validform_checktip"></span></dd>
                </dl>
                <dl class="form-group">
                    <dt>详细地址：</dt>
                    <dd>
                        <input name="address" value="" id="address" type="text" class="input">
                        <span class="Validform_checktip"></span></dd>
                </dl>
                <dl class="form-group">
                    <dt>手机号码：</dt>
                    <dd>
                        <input name="phone" id="phone" value="" type="text" class="input">
                        <span class="Validform_checktip"></span></dd>
                </dl>
                <dl class="form-group">
                    <dt>电子邮箱：</dt>
                    <dd>
                        <input name="email" id="email" type="text" value="" class="input" >
                        <span class="Validform_checktip"></span></dd>
                </dl>
                <dl class="form-group">
                    <dt>邮政编码：</dt>
                    <dd>
                        <input name="code" id="code" value=""  type="text" class="input">
                        <span class="Validform_checktip"></span></dd>
                </dl>
                <dl class="form-group">
                    <dd>
                        <input id="btnSubmit" name="btnSubmit" type="submit" value="确认提交" class="submit">
                    </dd>
                </dl>
            </div>
        </div>
    </div>
    <!--/页面左边-->
</form>  
</div>
<script type="text/javascript">
  function submitAddress(){
	  var username=$("#username").val();
	  var province=$("#province").val();
	  var city=$("#city").val();
	  var area=$("#area").val();
	  var address=$("#address").val();
	  var phone=$("#phone").val();
	  var email=$("#email").val();
	  var code=$("#code").val();
	  if(username==""){
		  alert("请输入姓名！");
		  return false;
	  }else if(province==""){
		  alert("请选择省!");
		  return false;
	  }else if(city==""){
		  alert("请选择市!");
		  return false;
	  }else if(area==""){
		  alert("请选择区！");
		  return false;
	  }else if(address==""){
		  alert("请选择地址信息！");
		  return false;
	  }else if(phone==""){
		  alert("请输入手机号码！");
		  return false;
	  }else if(email==""){
		  alert("请输入邮箱！");
		  return false;
	  }else if(code==""){
		  alert("请输入邮政编码");
		  return false;
	  }
	  
	  var url="${pathUrl}/home/center/submitAddEditorAddress";
	  $.post(url,$("#formMain").serializeArray(),function(resultObj){
		   if(resultObj.status==1){
			   alert(resultObj.msg);
			   window.location.href="${pathUrl}/home/center/addressIndex";
		   }else{
			   alert(resultObj.msg);
		   }
	  });
	  return false;
  }
</script>
</body>
</html>